class User < ActiveRecord::Base
  include Socialite::Models::UserConcern

  has_many :identities,
    :dependent => :destroy,
    :class_name => Socialite.identity_class_name,
    :foreign_key => :user_id

  validates :email,
    :presence => true,
    :format => { :with => /.+@.+\..+/i },
    :uniqueness => { :case_sensitive => false }

  attr_accessible :email, :password, :password_confirmation

  def self.find_from_omniauth(auth);           super; end
  def self.find_or_create_from_omniauth(auth); super; end
  def self.create_from_omniauth(auth);         super; end

  def auth_key; super; end
  def locate(search_hash_or_string); super; end

  def facebook; facebook_identity; end
  def twitter; twitter_identity; end

  # Set the user's remember token
  #
  # @return [User] the current user
  # def remember_me!
    # self.remember_token = Socialite.generate_token
    # save(:validate => false)
  # end

  # Clear the user's remember token
  #
  # @return [User] the current user
  # def forget_me!
    # if persisted?
      # self.remember_token = nil
      # save(:validate => false)
    # end
  # end
end

